package com.lu.sb210207.task;

import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@Slf4j
public class MyJob2 implements Job {

    //获取spring 上下文的Bean
    @Override
    public void execute(JobExecutionContext jobExecutionContext) {

        JobDetail jobDetail = jobExecutionContext.getJobDetail();
        JobDataMap jobDataMap = jobDetail.getJobDataMap();
        jobDataMap.forEach((k, v) -> System.out.println(k + "::" + v));

        // 执行业务逻辑
        System.out.println("这是一个有参数的Job任务调度实例，用于接收外部参数" + new Date().toLocaleString());

    }

}
